#ifndef CONNECTION_H
#define CONNECTION_H

#include <QObject>
#include <QQueue>

#include "curl/curl.h"


class Connection : public QObject
{
    Q_OBJECT

public:
    Connection();
    Connection(const Connection& other);
    ~Connection();

    void setHostname(const QString& hostname);
    QString hostname() const;

    void setHostPort(const QString& hostPort);
    QString hostPort() const;

    void setUsername(const QString& username);
    QString username() const;

    void setPassword(const QString& password);
    QString password() const;

    CURLcode connectToHost();
    void disconnectFromHost();

    QQueue<QString> exploreSftpFolderAndFiles(const QString& remotePath, const QString& filter) const;

    CURL* curl() const;

    bool isValid(QString url);

    enum Type { FileType, DirectoryType, InvalidType };
    Type isDir(const QString& url);

    QString toUrl() const;
private:
    void exploreSftpFolderAndFiles(const QString& remotePath, QQueue<QString>* remotePathList, const QString& filter) const;

    void setShareHandle(CURL* curl_handle);
private:
    QString m_hostname;
    QString m_hostPort;
    QString m_username;
    QString m_password;
    CURL* m_curl;
};

#endif // CONNECTION_H

